// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   EmojiConverterUtil.java

package novel.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class EmojiConverterUtil
{

    public EmojiConverterUtil()
    {
    }

    public static String emojiConvert1(String str)
    {
        String patternString = "([\\x{10000}-\\x{10ffff}\uD800-\uDFFF])";
        Pattern pattern = Pattern.compile(patternString);
        Matcher matcher = pattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        while(matcher.find()) 
            try
            {
                matcher.appendReplacement(sb, (new StringBuilder()).append("[[").append(URLEncoder.encode(matcher.group(1), "UTF-8")).append("]]").toString());
            }
            catch(UnsupportedEncodingException unsupportedencodingexception) { }
        matcher.appendTail(sb);
        return sb.toString();
    }

    public static String emojiRecovery2(String str)
    {
        String patternString = "\\[\\[(.*?)\\]\\]";
        Pattern pattern = Pattern.compile(patternString);
        Matcher matcher = pattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        while(matcher.find()) 
            try
            {
                matcher.appendReplacement(sb, URLDecoder.decode(matcher.group(1), "UTF-8"));
            }
            catch(UnsupportedEncodingException unsupportedencodingexception) { }
        matcher.appendTail(sb);
        return sb.toString();
    }
}
